-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Silence some warnings from derive(Properties) #2266
Conversation
I have difficulties replicating this in a test case since I don't know how |
|
adds a test case to check for several warnings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you for the PR!
My pleasure 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
The derive macro for
Properties
should preserve some attributes on fields.On the one hand, warnings on setters and fields of the generated builder are reported on the original field due to spanned quotes. It can be confusing to users that adding silencing annotations have no effect before this patch.
On the other hand,
cfg
attributes are passed on to work around an issue with rust-analyzer; Normallycfg
attributes are evaluated by the compiler before the token tree is passed to the proc-macro. rust-analyzer seems not to do that in some cases, but still generates errors and lints based on the result. When trying to connect those errors back to the source code, it reports "no-such-field" sincecfg
attributes on the original struct are respect and the field is invisible.To be clear,
cfg
attributes are not expected to show up during normal compilation, but are a quirk in some IDEs. In any case, it shouldn't hurt to respect them if they are found.Checklist
cargo make pr-flow